﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace GSF.Objects
{
    class EventMgr
    {
        Selected m_selected;
        Objects m_target;
        public EventMgr(Game game, string texture, int rows, int cols)
        {
            m_selected = new Selected(game, texture, rows, cols);
            
        }

        public void Update()
        {
            m_selected.update();
            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                m_target = CollisionMgr.Instance.getObject(new Rectangle((int)Mouse.GetState().X, (int)Mouse.GetState().Y, 1, 1));
                m_selected.Enable = m_target == null ? false : true;
            }
            if(m_selected.Enable)
                m_selected.Position = new Vector2(m_target.CenterPoint.X - m_selected.m_desRectangle.Width / 2, m_target.Position.Y + m_target.m_desRectangle.Height - m_selected.Height); 
        }
        public void Draw(SpriteBatch sprite)
        {
            if (m_selected.Enable)
                m_selected.Draw(sprite);
        }
    }
}
